import requset from './request.js'

export default async function logRequset(userInfo) {
	//请求登录获取code
	let userLogin = await wx.login({})
	let code = userLogin.code
	console.log(code)
	//添加登录的用户信息
	let userLog = await requset({
		url: '/v1/common/wx/login',
		method: 'POST',
		data: {
			"code": code,
			"rawData": JSON.stringify(userInfo)
		}
	})
	console.log("userLog", userLog)
	if (userLog.isSuccess) {
		console.log("userLog", userLog)
		//添加成功保存用户的openId
		// getApp().globalData.openId = userLog.data.openId
		getApp().globalData.userId = userLog.data.id
		// wx.navigateBack()
		// wx.switchTab({
		// 	url: '/pages/index/index.vue'
		// })
	}
}

